<template>
  <div>
  <van-nav-bar
  class="top"
  title="搜索如下"
  left-text="返回"
  left-arrow
  @click-left="onClickLeft"
/>
<van-card
v-for="(it,index ) in items"
:key="index"
 @click="tiaz(it.id)"
  :num="it.num"
  :price="it.price"
  desc="描述信息"
  :title="it.name"
  :thumb="it.imgs.split('||')[0]"
/>
  </div>
</template>

<script>
import { fetchDate } from '@api'
import { Toast } from 'vant'
export default {
  data () {
    return {
      cates: this.$route.query.key,
      items: {}
    }
  },
  created () {
    this.fetchDate()
  },
  methods: {
    tiaz (id) {
      this.$router.push({
        path: '/details',
        query: {
          id: id
        }
      })
    },
    onClickLeft () {
      history.go(-1)
    },
    fetchDate () {
      fetchDate({ query: this.cates }).then(res => {
        if (res.data.data.length) {
          this.items = res.data.data
        } else {
          Toast('暂无数据')
        }
      })
    }
  }

}
</script>

<style lang="scss" scoped>

</style>
